package com.lu.pojo.oop.classes;
/**
 * @author luzhenfang
 * @date 2020 2 24
 * @description 重写 equals 方法 MyDate 类
 */
public class MyDate {
    private int year;
    private int month;
    private int day;
    public static void main(String[] args) {
        MyDate myDate1 = new MyDate(2010, 3, 10);
        MyDate myDate2 = new MyDate(2020, 3, 10);
        System.out.println(myDate1.equals(myDate2));
    }

    @Override
    public boolean equals(Object o) {
        if(o instanceof MyDate){
            MyDate other =(MyDate)o;
            return this.year==other.year
                    &&this.month==other.month
                    &&this.day==other.day;
        }
        return false;
    }
    public int getYear() {
        return year;
    }
    public void setYear(int year) {
        this.year = year;
    }
    public int getMonth() {
        return month;
    }
    public void setMonth(int month) {
        this.month = month;
    }
    public int getDay() {
        return day;
    }
    public void setDay(int day) {
        this.day = day;
    }
    public MyDate() {
    }
    public MyDate(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }
}
